package com.weighing.web.controller.server;

import com.weighing.common.core.controller.BaseController;
import com.weighing.common.core.domain.AjaxResult;
import com.weighing.system.domain.server.ProduceOrder;
import com.weighing.system.service.server.ProduceOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 工单主表控制器
 * 提供工单主表及明细的查询接口
 */
@RestController
@RequestMapping("/produce/produceOrder")
public class ProduceOrderController extends BaseController {

    @Resource
    private ProduceOrderService produceOrderService;

    /**
     * 根据工单号查询工单信息及明细
     * @param billNo 工单号
     * @return 工单主表及对应的明细
     */
    @GetMapping("/getByBillNo/{billNo}")
    public AjaxResult getByBillNo(@PathVariable String billNo) {
        ProduceOrder order = produceOrderService.getByBillNo(billNo);
        if (order == null) {
            return AjaxResult.error("未找到对应工单号：" + billNo);
        }
        return AjaxResult.success(order);
    }

}
